package org.mybatis.generator.utils;

import org.apache.commons.lang.text.StrSubstitutor;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @author hedong
 * @date 2021/4/18
 */
public class StringParttenUtils {

    public static String replace(String templateString, Map<String, Object> paramsMap) {
        if (StringUtils.isBlank(templateString)) {
            return templateString;
        }
        StrSubstitutor sub = new StrSubstitutor(paramsMap);
        return sub.replace(templateString);
    }

    public  static void main(String[] args){
        Map<String, Object> map = new HashMap<>();
        map.put("name", "熊二");
        map.put("age", 3);
        System.out.println(replace("我叫${name},今年${age}岁", map));
    }

}
